package com.practice.exercise.dao;

import com.practice.exercise.domain.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface StudentMapper {

    @Select("select * from User where type=0")
    List<User> findAllStudent();

    @Select("select * from User where type=0 and id=#{user_id}")
    User findStudentById(int student_id);

    @Update("update User set name=#{name},age=#{age},sex=#{sex},phone=#{phone},address=#{address},grade=#{grade},cclass=#{cclass} where id=#{id} and type=0")
    void updateStudentInfo(User student);

    @Delete("delete from User where type=0 and id=#{student_id}")
    void deleteStudentById(int student_id);

    @Insert("insert into User(name,age,sex,phone,address,type,grade,cclass) values(#{name},#{age},#{sex},#{phone},#{address},0,#{grade},#{cclass})")
    void insertStudent(User student);

}
